import 'dart:math';

import 'package:dk_flutter_base/src/ui/clipper/clipper_trapezium.dart';
import 'package:dk_flutter_base/src/ui/widget/dk_color.dart';
import 'package:dk_flutter_base/src/ui/widget/dk_text.dart';
import 'package:dk_flutter_base/src/core/util/paint_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class TestTrapeziumWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(top: 50),
      child: ListView.builder(
        itemBuilder: (BuildContext context, int index) {
          double deg = 60;
          double offset = 142 - index * 31.5 * 2 / tan(degToRad(deg));
          print("offset===========" + offset.toString());
          return Container(
            padding: EdgeInsets.only(bottom: 8),
            child: Row(
              children: <Widget>[
                Expanded(
                  flex: 1,
                  child: Container(
                    padding: EdgeInsets.only(
                        left: index * 31.5 * 2 / tan(degToRad(deg)),
                        right: index * 31.5 * 2 / tan(degToRad(deg))),
                    child: ClipPath(
                      clipper: IsoscelesTrapeziumClipper.deg(deg),
                      child: Container(
                        width: 0,
                        height: 23.5,
                        color: Colors.blue,
                        alignment: AlignmentDirectional.center,
                        child:
                            DkText.simple(3.toString() + "%", 12, Colors.white),
                      ),
                    ),
                  ),
                ),
                Padding(
                  padding: EdgeInsets.only(left: 33.5),
                  child: Container(
                    height: 12,
                    width: 12,
                    color: Colors.red,
                  ),
                ),
                Padding(
                  padding: EdgeInsets.only(left: 5.5),
                  child: DkText.simple("111111", 14, Color(0xff333333)),
                ),
                Padding(
                  padding: EdgeInsets.only(left: 10),
                  child: DkText.simple("2222222", 14, Color(0xff333333)),
                ),
              ],
            ),
          );
        },
        itemCount: 2,
        shrinkWrap: true,
        padding: EdgeInsets.only(bottom: 8),
        controller: ScrollController(keepScrollOffset: false),
      ),
    );
  }
}
